﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Add.aspx.cs" Inherits="WinnerCMS.WebUI.Admin.Role.Add" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <%: Styles.Render("~/Content/Bootstrap/css") %>
    <%: Scripts.Render("~/Scripts/AdminBase") %>

    <title>添加角色</title>
    <script type="text/javascript">
        function SelectAll(me) {
            $("input[name='chkOperation']").each(function () {
                this.checked = me.checked;
            });
        }
        function AreaSelectAll(me) {
            $(me).parents("fieldset").find("input[name='chkOperation']").each(function () {
                this.checked = me.checked;
            });
        }

        $(function () {
            $(".showCategoryPermission").click(function (e) {
                var roleid = $(e.delegateTarget).data("roleid");
                $.jqopen("../Class/Permission.aspx?roleid=" + roleid, { title: "栏目权限", width: 700, height: 500 });
            });
        });
    </script>
    <style>
        .showCategoryPermission {
            cursor: pointer;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <table class="table">
            <tr class="HeaderStyle">
                <td>角 色 添 加
                </td>
            </tr>
            <tr>
                <td class="border">
                    <div>
                        角色名称：
                        <asp:TextBox ID="txtRoleName" runat="server"></asp:TextBox><asp:Button ID="btnAdd"
                            runat="server" Text="添加" OnClick="btnAdd_Click" CssClass="btn btn-default" />
                    </div>
                    <div class="control-group checkbox">
                        <asp:CheckBox ID="cbkALL" onclick="javascript:SelectAll(this);" runat="server" Text="全选" />
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:DataList ID="DataList1" runat="server" Width="100%" CellPadding="8" BorderWidth="0"
                        RepeatColumns="1" RepeatDirection="Horizontal" HorizontalAlign="Center">
                        <ItemStyle VerticalAlign="Top" BorderColor="ActiveBorder" />
                        <ItemTemplate>
                            <fieldset>
                                <legend>
                                    <%# Container.ItemIndex + 1 %>、<%# Eval("Name") %><input id="root<%# Eval("ID") %>"
                                        onclick="AreaSelectAll(this);" type="checkbox" title="<%# Eval("Code") %>" /></legend>
                                <asp:DataList ID="Datalist2" runat="server" Width="100%" RepeatColumns="5" RepeatDirection="Horizontal"
                                    DataSource='<%# BindPower(Eval("RootID")) %>'>
                                    <ItemStyle VerticalAlign="Top" Width="240" Wrap="true" />
                                    <ItemTemplate>
                                        <div class="control-group checkbox">
                                            <input id="cbk<%# Eval("ID") %>" type="checkbox" name="chkOperation" value='<%# Eval("ID") %>'
                                                title='<%# Eval("Code") %>' /><label for="cbk<%# Eval("ID") %>" title="<%# Eval("Code") %>"><%# Eval("Name") %></label>
                                        </div>
                                    </ItemTemplate>
                                </asp:DataList>
                            </fieldset>
                        </ItemTemplate>
                    </asp:DataList>
                </td>
            </tr>
        </table>
    </form>
</body>
<script type="text/javascript">    //复选框选择值
    function CheckValues(strValue) {
        if (strValue == "") return;

        $("input[name='chkOperation']").each(function () {
            if (strValue.indexOf("," + this.value + ",") >= 0) {
                this.checked = true;
            }

        });
    }
    //初始化权限
    CheckValues(",<%= strOperation %>,");
</script>
</html>
